package GreedyAlgorithm;
/*
 * 分发饼干
 */
import java.util.Arrays;

public class lc455 {

    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int index = s.length - 1;
        int result = 0;
        for (int i = g.length - 1; i >= 0; i --) {
            if (index >= 0 && g[i] <= s[index]) {
                index--;
                result++;
            }
        }
        return result;
    }
    
}
